//
//  WXSAlertViewController.m
//  SleepBooks
//
//  Created by rimi on 16/9/21.
//  Copyright © 2016年 rimi. All rights reserved.
//

#import "WXSAlertViewController.h"

@interface WXSAlertViewController ()

@end

@implementation WXSAlertViewController

- (instancetype)initWithTitle:(NSString *)title message:(NSString *)message actionTitle:(NSString *)actionTitle action:(SEL)action
{
    self = [super init];
    if (self) {
        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction *alertAction = [UIAlertAction actionWithTitle:actionTitle style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
            //当点取消按钮时执行block里面方法
            [self dismissViewControllerAnimated:YES completion:nil];
        }];
        //添加确定按钮
        [alertController addAction:alertAction];
        //因为alert是一个控制器，所以需要用控制器的跳转方式弹出
        [self presentViewController:alertController animated:YES completion:nil];
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
